This patch to 4am crack of Summer Games II
celebrates Catalonia Declaration of Independence 
on 27 October 2017.

The original patch dates back to 1987 or earlier
and used as basis the HOT ROD crack of that era. 

The patch consists in being able to compete for Catalonia.

The game allows each player to select one of 17 country 
flags from the eighties or the Epyx team flag to compete.

As a bonus when the country is selected the national anthem
for the chosen country plays.

At the end of each event, the flag of the winner is shown
and the national anthem can be heard again through the
apple speaker.

To include Catalonia as an option I had to sacrifice another
country and guess what... the game designers included the flag
of Franco's dictatorship instead of the valid spanish flag
since 1978.

So the hacker decision was a no-brainer, the catalan flag
shares horizontal stripes and colors with the spanish flag:
two red stripes for Spain, four red stripes for Catalonia.

The trickiest part was to guess which bytes held the anthems.

Back then I did not know how to write CATALONIA in english
so when choosing the flag it read CATALUNYA written 
in the Catalan language. This is what this patch fixes.
The country abbreviation (CAT) stood the test of time.

Also, instead of releasing it as a patch to the HOT ROD crack,
I was curious if it would work on 4am crack... and it worked!

Here the transcript.

--------- Summer Games II ----------
Catalonia patch to 4am crack celebrates
Declaration of Independence on 27-Oct-2017.
------------------------------------

The idea is to compare my 30 year old patch
to HOT ROD crack with 4am crack and patch it!

Split each disk image into 35 smaller files 
which will represent the disks tracks. 
A track holds 16 sectors of 256 bytes, 4096 bytes total. 
To handle 35 files per disk image put them
in separate folders d1 and d2.

The $ sign indicates commands to type right away 
from the Terminal on Mac OS X.

$ mkdir d1
$ mkdir d2
$ split -b 4096 sg2_4am_crack_side_1.dsk d1/x
$ split -b 4096 sg2_hotrod_crack_catalonia_side_1.dsk d2/x

How do the tracks compare on each side?
Hash each track on side 1 of both cracks and compare lines.

$ md5 d1/* | cut -d/ -f2 > d1.txt
$ md5 d2/* | cut -d/ -f2 > d2.txt

Only the first five tracks differ between both cracks!

The tracks naming convention is: 
1 -> xaa, 2 -> xab, 3 -> xac, 4 >- xad, ..

$ diff d1.txt d2.txt
1,5c1,5
< xaa) = ddc1dd9363d6084375d0b24ac32c2a2a
< xab) = 3e32e2c3e38060f429c0f15a1a78c218
< xac) = bffa8c8ab0a94cbccdbc52f7cf4cb3ce
< xad) = fa547c055793dee34e6529e4f78e33e9
< xae) = 5b752aeb9d9ebe6cddb7b06a06e8c99f
---
> xaa) = 2794f8462b0a0f2ab402f9cd42b525bc
> xab) = 7231d8a97b62b4fb2e8053d49ea1dafd
> xac) = fd6a8715b49355d26583db3c9a732169
> xad) = 5faa1aa1c9775ab44f5dab382e4cca34
> xae) = 28d00beea0ce0d183a2355f0fb71d7ea

For each track that differs use xxd to
obtain the combined hex and ascii view
which makes me feel a bit closer to
Copy ][ Plus sector editor!

$ xxd d1/xaa > d1_xaa
$ xxd d1/xab > d1_xab
$ xxd d1/xac > d1_xac
$ xxd d1/xad > d1_xad
$ xxd d1/xae > d1_xae
$ xxd d2/xaa > d2_xaa
$ xxd d2/xab > d2_xab
$ xxd d2/xac > d2_xac
$ xxd d2/xad > d2_xad
$ xxd d2/xae > d2_xae

The first track on side 1 includes the high scores 
(cleared by 4am, not on my play disk).

Track 2 holds the country acronyms.. 
My play disk switches ESP->CAT. Let's have a look:

$ diff d1_xab d2_xab
244c244
< 00000f30: 5420 4954 4120 4553 5020 4445 4e20 4155  T ITA ESP DEN AU
---
> 00000f30: 5420 4954 4120 4341 5420 4445 4e20 4155  T ITA CAT DEN AU

Track 3 holds some country flags... they differ again, 
a country flag was swapped on my play disk!

Track 4 holds country names, oh! back then I did not know 
the english name for CATALUNYA.
$ diff d1_xad d2_xad
56c56
< 00000370: d920 2053 5041 494e 2020 2020 2020 2044  .  SPAIN       D
---
> 00000370: d943 4154 414c 4f4e 4941 2020 2020 2044  .CATALUNYA     D

Change CATALUNYA to CATALONIA with my favourite editor 
on the HEX part of the file. That is guessing by context which 
letter is which. 49 => I and so on.
Convert back the hex view to a new file and replace track 4 on 4am crack.

$ xxd -r d2_xad zad
$ cp zad d1/xad


Track 5 holds the national anthems that differ, again my fault!

Replace tracks 2,3 and 5 on 4am crack with tracks 2,3 and 5 on my play disk.

$ cp d2/xab d1/xab
$ cp d2/xac d1/xac
$ cp d2/xae d1/xae

Rebuild the 4am crack with the Catalonia patch.

$ cat d1/x?? > sg2_4am_crack_catalonia_patch_side_1.dsk 

Repeat process for side two of the disk on both cracks (folders e1 and e2).
The same tracks differ on side 2... it is true, country flags and national anthems are on
both sides to avoid disk swapping when collecting the medals!

Remove temp files and folders.

Enjoy!

@A2_POET

